//
//  AboutUsVC.m
//  HengYouCai
//
//  Created by ycgwl on 2017/5/4.
//  Copyright © 2017年 lwj. All rights reserved.
//

#import "AboutUsVC.h"
#import "BannerWebViewVC.h"
#import "BannerWebViewVC.h"
#import "FeedBackVC.h"

@interface AboutUsVC ()
@property (weak, nonatomic) IBOutlet UILabel *versionLab;
@property (weak, nonatomic) IBOutlet UILabel *infoLab;
@property (nonatomic, retain)NSArray *titleArr;
@end

@implementation AboutUsVC
- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;

    NSString *compony = [WLFileManager readUserDataForKey:kCompony];
    NSString *recordNum = [WLFileManager readUserDataForKey:KRecordNum];
    _infoLab.text = [NSString stringWithFormat:@"%@\n%@",compony,recordNum];

}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = self.titleName; // @"关于我们"
    self.view.backgroundColor = Normal_BackColor;
    NSDictionary *dict = [[NSBundle mainBundle] infoDictionary];
//    CFShow(infoDictionary);
    NSString *app_Version = [dict objectForKey:@"CFBundleShortVersionString"];
    _versionLab.text = [NSString stringWithFormat:@"子壹财富 v %@",app_Version];
    
    //点击显示渠道
    UIView * iconView = [self.view viewWithTag:10];
    iconView.userInteractionEnabled = YES;
    
    UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(iconViewClick)];
    
    [iconView addGestureRecognizer:tap];
    
}

- (void)iconViewClick
{
    static BOOL flag = YES;
    if (flag) {
        _versionLab.text = [NSString stringWithFormat:@"子壹财富：%@",kChannel_app];
    }else{
        NSDictionary *dict = [[NSBundle mainBundle] infoDictionary];
        NSString *app_Version = [dict objectForKey:@"CFBundleShortVersionString"];
        _versionLab.text = [NSString stringWithFormat:@"子壹财富 v %@",app_Version];
    }
    flag = !flag;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.titleArr.count;
}
#pragma tableviewDelegate

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"aboutUsCellID"];
    UILabel *titleLab = [cell viewWithTag:1001];
    UIView *view = [cell viewWithTag:1003];
    view.hidden = indexPath.row==2;
    titleLab.text = _titleArr[indexPath.row];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    switch (indexPath.row) {
        case 0:
        {
            BannerWebViewVC *web = [[BannerWebViewVC alloc] initWithUrlStr:self.platformIntroUrl title:self.platformIntro];
            [self.navigationController pushViewController:web animated:YES];
        }
            break;
        case 1:
        {
            FeedBackVC *VC = (FeedBackVC *)[[UIStoryboard storyboardWithName:@"Profile" bundle:nil] instantiateViewControllerWithIdentifier:@"FeedBackVCID"];
            VC.titleName = self.feedback;
            [self.navigationController pushViewController:VC animated:YES withHideBottomBarWhenPush:YES pop:YES];

        }
            break;
        case 2:
        {
            UIViewController *VC = [[UIStoryboard storyboardWithName:@"Profile" bundle:nil] instantiateViewControllerWithIdentifier:@"FeedBackVCID"];
            [self.navigationController pushViewController:VC animated:YES withHideBottomBarWhenPush:YES pop:YES];
        }
            break;
        default:
            break;
    }
    
}
- (NSArray *)titleArr
{
    if (!_titleArr) {
        _titleArr = @[self.platformIntro, self.feedback];
    }
    return _titleArr;
}
@end
